// Enesea Linux Window
// (c) jimon game studio

#ifndef JEH_CWINDOW_LINUX
#define JEH_CWINDOW_LINUX

#include "IWindow.h"

#ifdef JE_DEVICE_LINUX

#include <GL/glx.h>
#include <X11/X.h>
#include <X11/extensions/xf86vmode.h>

namespace je
{
	namespace device
	{
		//! Linux Window
		class CWindow_Linux:public je::device::IWindow
		{
		protected:
			jeStringd WindowClassName;

			Display * CurrentDisplay;
			s32 CurrentScreen;
			Window CurrentWindow;

			GLXFBConfig * FrameBufferConfig;
			XVisualInfo * CurrentVisualInfo;
			XF86VidModeModeInfo LastDesktopMode;

			u1 FullScreenMode;
			u1 WindowActived;
			u1 MainWindow;

			u1 NeedClose;

			jeVector2di Size;
			jeVector2di Position;
			s32 CurrentDepth;
			s32 CurrentHertz;
			s32 CurrentMSAA;

			input::IMouseDriver * MouseDriver;
			input::IKeyDriver * KeyDriver;
		public:
			//! Constructor
			CWindow_Linux(Display * XDisplay,const jeVector2di & size,const jeStringd & Title,u1 fullscreen,s32 depth,s32 hertz,s32 msaa);

			//! Destructor
			~CWindow_Linux();

			//! Set Window Active
			void SetActive(u1 Active);

			//! Set Close Flag
			void SetCloseFlag(u1 Close);

			//! Resize Window
			void Resize(const jeVector2di & NewSize);

			//! Set Size
			void SetSize(const jeVector2di & NewSize);

			//! Get Size
			const jeVector2di & GetSize();

			//! Set Window Position
			void SetPosition(const jeVector2di & NewPosition);

			//! Get Window Position
			const jeVector2di & GetPosition();

			//! Set Fullscreen Mode
			void SetFullScreen(u1 FullScreenn,const jeVector2di & NewSize,s32 Depth = 0,s32 Hertz = 0);

			//! Return true if fullscreen
			u1 IsFullScreen();

			//! Get Depth
			s32 GetDepth();

			//! Get Hertz
			s32 GetHertz();

			//! Get MSAA
			s32 GetMSAA();

			//! Set Window Title
			void SetTitle(const jeStringd & Title);

			//! Get Window Title
			jeStringd GetTitle();

			//! Set Main Window flag
			void SetMainWindow(u1 Main);

			//! Return Main Window flag
			u1 IsMainWindow();

			//! Return true if someone try to close window
			u1 IsNeedToClose();

			//! Return true if window active
			u1 IsActive();

			//! Set Focus on window
			void SetWindowFocus();

			//! Get Mouse Driver
			input::IMouseDriver * GetMouseDriver();

			//! Get Key Driver
			input::IKeyDriver * GetKeyDriver();

			//! Get Window Api Pointer
			void * GetWindowApiPointer(WindowApiPointerType Type);

			//! Get Window
			Window GetWindow()
			{
				return CurrentWindow;
			}
		};
	}
}

#endif

#endif
